#include "showtext.h"
#include <QPainter>
#include <QTimer>

ShowText::ShowText(QWidget *parent) :
    QWidget(parent)
{
    setFont(QFont("wenquanyi", 20));

    m_text = QObject::trUtf8("欢迎进入广告机管理系统, 陕西理工学院计算机科学与技朮系－计本074  E-mail:loveu089@163.com   QQ:876436155    ");
    update();

    QTimer* timer = new QTimer;
    timer->start(300);
    connect(timer, SIGNAL(timeout()), this, SLOT(onChange()));
}

void ShowText::paintEvent(QPaintEvent *)
{
    QPainter p(this);
    QPen thickPen(Qt::black, 5);
    p.setPen(thickPen);
    p.drawText(0, 0, width(), height(), Qt::AlignLeft | Qt::AlignVCenter, m_text);
}

void ShowText::onChange()
{
    QChar ch = m_text.at(0);
    m_text.remove(0, 1);
    m_text.append(ch);
    update();
}
